/*
 * Copyright (C) 2010 http://laantiguafragua.blogspot.com
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * SimpleFileUpdate.java
 *
 * Created on 02/24/2010
 */
package simplefileupdate;

import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;

/**
 * This class contains a series of FileData, these FileData contains the
 * information of the files in the source or destiny
 * @author lhrod
 */
public class VersionData {

    private Hashtable fileHash = new Hashtable();
    private ArrayList news = new ArrayList();

    public void addFile(int id, String name, Date date, URL url, String version) throws Exception {
        addFile(id, name, date, url, version, -1, false);
    }

    public void addFile(int id, String name, Date date, URL url, String version, long size, boolean reloadApp) throws Exception {
        if (!fileHash.containsKey(id)) {
            fileHash.put(id, new FileData(id, name, date, url, version, size, reloadApp));
        } else {
            throw new Exception("Two files in \"VersionData\" shared \"id\"");
        }
    }

    void addNews(String tNews) {
        news.add(tNews);
    }

    void addNews(String tNews, int id) {
        ((FileData) fileHash.get(id)).addNews(tNews);
    }

    public Hashtable getFileHash() {
        return fileHash;
    }

    public String [] getNews()
    {
        return (String[]) news.toArray(new String[]{});
    }
}
